import xlrd
import os
def read_excel(path):
    # f1, f2 = os.path.split(path)
    # print(f2)
    data = xlrd.open_workbook('/' + path)
    sheet_names = data.sheet_names()
    for sn in sheet_names:
        sheet = data.sheet_by_name(sn)
        print(sheet.row_values(1))


def parse_file(datafile):
    workbook = xlrd.open_workbook(datafile)
    sheet = workbook.sheet_by_index(0)

    data = [[sheet.cell_value(r, col) for col in range(sheet.ncols)] for r in range(sheet.nrows)]
    # 获取第一列的所有值（coast)
    print(data)
    for i in data:
        for k in i:
            pass

    # cv = sheet.col_values(1, start_rowx=1, end_rowx=None)
    #
    # maxval = max(cv)
    # minval = min(cv)
    #
    # maxpos = cv.index(maxval) + 1
    # minpos = cv.index(minval) + 1
    #
    # maxtime = sheet.cell_value(maxpos, 0)  # 表格中第0列是时间
    # realmaxtime = xlrd.xldate_as_tuple(maxtime, 0)
    # mintime = sheet.cell_value(minpos, 0)  # 表格中第0列是时间
    # realmintime = xlrd.xldate_as_tuple(mintime, 0)
    #
    # data = {
    #     'maxtime': realmaxtime,
    #     'maxvalue': maxval,
    #     'mintime': realmintime,
    #     'minvalue': minval,
    #     'avgcoast': sum(cv) / float(len(cv))
    # }
    #
    # return data

if __name__=="__main__":
    path = 'fileData2/ST/file_manager/customer_info/customer_info.xlsx'
    parse_file('/' + path)